<template>
  <div class="component-wrapper">
    <div class="top-wrapper">
      <div class="title" style="padding-top: 0">本日新增税费收入</div>
      <div class="num-list">
        {{ todayData.brxzsfsr }}
        <div class="num-item yellow"></div>
      </div>
      <div class="dw">万元</div>
    </div>
    <div class="content-wrapper">
      <img src="~@/assets/images/icon-11.png" class="icon-wrapper" />
      <div class="item">
        <div class="title">本年累计税费收入</div>
        <div class="num-wrapper">
          <div class="money">{{ EchartData.bnljsfsr }}</div>
          <div class="money-dw">亿元</div>
          <img
            class="tag"
            v-if="EchartData.bnljsfsrtbs > 0"
            src="~@/assets/images/topIcon.png"
          />
          <img
            class="tag"
            v-if="EchartData.bnljsfsrtbs < 0"
            src="~@/assets/images/downIcon.png"
          />
          <div class="percent">{{ EchartData.bnljsfsrtbs }}%</div>
        </div>
      </div>
      <div class="item">
        <div class="num-wrapper">
          <img class="icon" src="~@/assets/images/middleTopIcon_01.png" />
          <div class="money small">{{ EchartData.bnljsfsrzsje }}</div>
          <div class="money-dw small">亿元</div>
          <img
            class="tag small"
            v-if="EchartData.bnljsfsrzsjetbs > 0"
            src="~@/assets/images/topIcon.png"
          />
          <img
            class="tag small"
            v-if="EchartData.bnljsfsrzsjetbs < 0"
            src="~@/assets/images/downIcon.png"
          />
          <div class="percent">{{ EchartData.bnljsfsrzsjetbs }}%</div>
        </div>
        <div class="num-wrapper">
          <img class="icon" src="~@/assets/images/middleTopIcon_02.png" />
          <div class="money small">{{ EchartData.bnljsfsrzfsje }}</div>
          <div class="money-dw small">亿元</div>
          <img
            class="tag small"
            v-if="EchartData.bnljsfsrzfsjetbs > 0"
            src="~@/assets/images/topIcon.png"
          />
          <img
            class="tag small"
            v-if="EchartData.bnljsfsrzfsjetbs < 0"
            src="~@/assets/images/downIcon.png"
          />
          <div class="percent">{{ EchartData.bnljsfsrzfsjetbs }}%</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { FormateDate } from "@/utils/util.js";

export default {
  inject: ["reload"],
  name: "sstjzs",
  data() {
    return {
      prevDate: "",
      EchartData: [],
      yearDate: "",
      todayData: {},
      timer: null,
      nextUpdateTime: null,
    };
  },
  created() {
    let date = "";
    let month = new Date().getMonth() + 1;
    let year = new Date().getFullYear();
    let day = new Date().getDate();
    date = year + "-" + month + "-" + day;
    this.prevDate = date;
    this.yearDate = year;
  },
  mounted() {
    this.ajax({
      url: "/dpzsSycxService/sstjzsQuery",
      method: "post",
      data: {
        param: {
          tjnd: this.yearDate,
        },
      },
    }).then((res) => {
      res = res.data;
      if (res.rtnCode !== "200") {
        this.$message.error(res.rtnMsg);
        return;
      }
      this.EchartData = res.data;
    });
    //本日新增税费收入
    this.getTodayData();
    this.timer = setInterval(() => {
      if (this.nextUpdateTime && this.nextUpdateTime == FormateDate()) {
        this.getTodayData();
      }
    }, 1000);
  },
  methods: {
    getTodayData() {
      this.ajax({
        url: "/dpzsSycxService/sstjzsbrxzQuery",
        method: "post",
        data: {
          param: {
            tjrq: this.prevDate,
          },
        },
      }).then((res) => {
        res = res.data;
        if (res.rtnCode !== "200") {
          this.$message.error(res.rtnMsg);
          return;
        }
        this.todayData = res.data;
        this.nextUpdateTime = res.data.xcsxsj;
        this.reload();
      });
    },
  },
  beforeDestroy() {
    clearInterval(this.timer);
    this.timer = null;
  },
  // 离开页面后执行函数
  destroyed: function () {},
};
</script>

<style scoped lang="scss">
.component-wrapper {
  width: 926px;
  height: 206px;
  .top-wrapper {
    display: flex;
    height: 36px;
    justify-content: center;
    align-items: baseline;
    .title {
      font-size: 20px;
      margin-right: 6px;
      font-weight: bold;
      color: #ffffff;
    }
    .num-list {
      margin: 0 2px 0 8px;
      font-size: 30px;
      color: #fbe671;
      font-weight: bold;
    }
    .dw {
      margin-left: 6px;
      font-size: 16px;
      color: rgba(251, 230, 113, 1);
    }
  }
  .content-wrapper {
    padding-top: 24px;
    padding-bottom: 32px;
    box-sizing: border-box;
    display: flex;
    justify-content: center;
    background: url("~@/assets/images/bg-item-11.png") no-repeat;
    background-size: 700px 30px;
    background-position: center bottom;
    .icon-wrapper {
      width: 102px;
      height: 90px;
    }
    .item {
      margin: 0 12px;
      height: 100px;
      display: flex;
      flex-direction: column;
      justify-content: center;
      .title {
        margin-top: 4px;
        font-weight: 700;
        font-size: 20px;
        color: #ffffff;
      }
      .num-wrapper {
        flex: 0 0 50px;
        height: 50px;
        display: flex;
        align-items: center;
      }
      .money {
        font-weight: 700;
        font-size: 34px;
        color: #fbe671;
        &.small {
          font-size: 20px;
        }
      }
      .money-dw {
        margin-top: 6px;
        margin-left: 6px;
        font-weight: 700;
        font-size: 20px;
        color: #fbe671;
        &.small {
          margin-top: 4px;
          font-size: 14px;
        }
      }
      .tag {
        width: 20px;
        height: 28px;
        margin: 0 6px;
        &.small {
          width: 18px;
          height: 26px;
        }
      }
      .percent {
        font-size: 16px;
        color: rgba(172, 214, 255, 1);
      }
      .icon {
        width: 68px;
        height: 68px;
      }
    }
  }
}
</style>
